Skip to content

feat: kiloclaw chat rework#9764

Open
catrielmuller wants to merge 7 commits intomainfrom
catrielmuller/new-kiloclaw-chat-vscode
Open

feat: kiloclaw chat rework#9764
catrielmuller wants to merge 7 commits intomainfrom
catrielmuller/new-kiloclaw-chat-vscode

Conversation

@catrielmuller
Copy link
Copy Markdown
Contributor

@catrielmuller catrielmuller commented May 1, 2026

Context

Migrate the KiloClaw chat from the Stream Chat SaaS to Kilo's own kilo-chat backend so both the VS Code panel and the CLI TUI match the web UX at app.kilo.ai/claw/kilo-chat: multiple conversations, reactions, typing indicators, edits/deletes, reply threading, and in-chat action approvals. This also removes the stream-chat dependency (and its Bun patch) from both kilo-vscode and opencode packages.

Implementation

  • Gateway (packages/kilo-gateway): kilo.claw.chatCredentials now returns { token, expiresAt, kiloChatUrl, eventServiceUrl } instead of Stream credentials. The bearer is the user's existing Kilo JWT — kilo-chat and event-service verify it directly, so no extra token mint is needed. URLs are read from KILO_CHAT_URL / EVENT_SERVICE_URL env vars with sensible defaults.
  • Extension host (packages/kilo-vscode/src/kiloclaw/): new KiloChatClient (HTTP), EventServiceClient (WebSocket with JWT-via-subprotocol auth, reconnect, resubscribe, heartbeat), and TokenManager (cached minting with cooldown). KiloClawProvider is the single source of truth — it owns conversations, active-conversation messages, typing, bot status, optimistic sends, and reaction/action reconciliation, and fans state out to the webview over a typed postMessage protocol.
  • Webview (packages/kilo-vscode/webview-ui/kiloclaw/): new ConversationList, MessageArea, and expanded MessageBubble (reactions, edit/delete, reply preview, action approvals, toolbar), plus sidebar context-window meter and bot-status section. i18n strings added for all locales.
  • TUI (packages/opencode/src/kilocode/claw/): ported to the same backend with a single-conversation view, slash commands (/new, /conversations), autocomplete, and the same sidebar layout.
  • SDK: regenerated from packages/sdk/openapi.json (new response shape + botName on status). stream-chat@9.38.0 and its patch removed from both packages.

Screenshots

image image image image image image image image image image image image image image image image

How to Test

  • bun run extension --no-build (or bun run extension) to launch the extension against a dev backend, open the KiloClaw panel, and verify:
    • Conversation list loads and groups by recency; /new, rename, and leave work.
    • Messages send and stream token-by-token; typing indicator appears while the bot is responding.
    • Reactions, edit, delete, and reply threading round-trip.
    • Action approval buttons resolve and persist after reload.
    • Sidebar shows bot status dot and context-window usage updating as the conversation grows.
  • bun run dev -- tui → open the KiloClaw view:
    • /conversations opens the picker; selecting one loads its history.
    • /new creates a fresh conversation and switches to it.
    • Messages, typing, and bot status update live.

Comment thread packages/kilo-vscode/src/kiloclaw/kilo-chat-client.ts Outdated
Comment thread packages/opencode/src/kilocode/claw/kilo-chat-client.ts Outdated
@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented May 1, 2026

Code Review Summary

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
packages/kilo-vscode/src/kiloclaw/event-service-client.ts 197 WebSocket can be opened after disconnect while ticket fetch is in flight
packages/opencode/src/kilocode/claw/event-service-client.ts 194 WebSocket can be opened after disconnect while ticket fetch is in flight

Fix these issues in Kilo Cloud

Other Observations (not in diff)

Issues found in unchanged code that cannot receive inline comments:

File Line Issue
- - None
Files Reviewed (2 files)
  • packages/kilo-vscode/src/kiloclaw/event-service-client.ts - 1 carried-forward issue
  • packages/opencode/src/kilocode/claw/event-service-client.ts - 1 carried-forward issue

Reviewed by gpt-5.5-20260423 · 1,084,190 tokens

const SUBPROTOCOL_PREFIX = "kilo.jwt."
const HANDSHAKE_TIMEOUT_MS = 10_000
const PING_INTERVAL_MS = 15_000

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try {
parsed = JSON.parse(data)
} catch {
return
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a debug dump here?

setConnected(true)
setLoading(false)
} catch (err: any) {
} catch (err) {
const e = err as { message?: string; name?: string; code?: string; stack?: string }
log.error("connect failed", {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe add an instanceof guard for type safety

@catrielmuller catrielmuller force-pushed the catrielmuller/new-kiloclaw-chat-vscode branch from 0d76566 to f409705 Compare May 6, 2026 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants